/*
 * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Autogenerated file -- DO NOT EDIT!

static const char *GetComponentTag(Logger::Component component)
{
% LoggerData.components.each do |c|
    if (component == Logger::Component::<%= c.enum %>) {
        return "<%= c.name %>";
    }
% end

    UNREACHABLE();
}

static const char *GetLevelTag(Logger::Level level)
{
% LoggerData.levels.each do |l|
    if (level == Logger::Level::<%= l.enum %>) {
        return "<%= l.tag %>";
    }
% end

    UNREACHABLE();
}

/* static */
Logger::Level Logger::LevelFromString(std::string_view s)
{
% LoggerData.levels.each do |l|
    if (s == "<%= l.name %>") {
        return ark::Logger::Level::<%= l.enum %>;
    }
% end

    UNREACHABLE();
}

/* static */
Logger::ComponentMask Logger::ComponentMaskFromString(std::string_view s)
{
% LoggerData.components.each do |c|
    if (s == "<%= c.name %>") {
        return ark::Logger::ComponentMask().set(Logger::Component::<%= c.enum %>);
    }
% end

    if (s == "all") {
        return ark::LOGGER_COMPONENT_MASK_ALL;
    }

    UNREACHABLE();
}

/* static */
std::string Logger::StringfromDfxComponent(LogDfxComponent dfxComponent)
{
    switch (dfxComponent) {
% LoggerData.dfx_components.each do |c|
    case Logger::LogDfxComponent::<%= c.enum %>:
        return "<%= c.name %>";
% end
    default:
        break;
    }
    UNREACHABLE();
}

/* static */
bool Logger::IsInLevelList(std::string_view s)
{
% LoggerData.levels.each do |l|
    if (s == "<%= l.name %>") {
        return true;
    }
% end

    return false;
}

/* static */
bool Logger::IsInComponentList(std::string_view s)
{
% LoggerData.components.each do |c|
    if (s == "<%= c.name %>") {
        return true;
    }
% end

    if (s == "all") {
        return true;
    }
    return false;
}

/* static */
uint32_t Logger::GetLevelNumber(Logger::Level level)
{
    switch (level) {
% LoggerData.levels.each do |l|
    case Logger::Level::<%= l.enum %>:
        return <%= l.value %>;
% end
    default:
        break;
    }

    UNREACHABLE();
}
